/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.jili.ubert.dao.trace;

import java.io.Serializable;

import com.baidu.bjf.remoting.protobuf.Codec;
import com.baidu.bjf.remoting.protobuf.ProtobufProxy;
import com.baidu.bjf.remoting.protobuf.annotation.Protobuf;
import com.jili.ubert.code.CodeTool;
import java.io.IOException;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author dragon
 */
@Entity
@Table(name = "trace_product_unit")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "TraceProductUnit.findAll", query = "SELECT t FROM TraceProductUnit t"),
    @NamedQuery(name = "TraceProductUnit.findBySid", query = "SELECT t FROM TraceProductUnit t WHERE t.sid = :sid"),
    @NamedQuery(name = "TraceProductUnit.findByTraceType", query = "SELECT t FROM TraceProductUnit t WHERE t.traceType = :traceType"),
    @NamedQuery(name = "TraceProductUnit.findByUnitID", query = "SELECT t FROM TraceProductUnit t WHERE t.unitID = :unitID"),
    @NamedQuery(name = "TraceProductUnit.findByProductID", query = "SELECT t FROM TraceProductUnit t WHERE t.productID = :productID"),
    @NamedQuery(name = "TraceProductUnit.findByUnitName", query = "SELECT t FROM TraceProductUnit t WHERE t.unitName = :unitName"),
    @NamedQuery(name = "TraceProductUnit.findByNet", query = "SELECT t FROM TraceProductUnit t WHERE t.net = :net"),
    @NamedQuery(name = "TraceProductUnit.findByShare", query = "SELECT t FROM TraceProductUnit t WHERE t.share = :share"),
    @NamedQuery(name = "TraceProductUnit.findByStartDate", query = "SELECT t FROM TraceProductUnit t WHERE t.startDate = :startDate"),
    @NamedQuery(name = "TraceProductUnit.findByEndDate", query = "SELECT t FROM TraceProductUnit t WHERE t.endDate = :endDate"),
    @NamedQuery(name = "TraceProductUnit.findByBelongGroupID", query = "SELECT t FROM TraceProductUnit t WHERE t.belongGroupID = :belongGroupID"),
    @NamedQuery(name = "TraceProductUnit.findByOwnUserID", query = "SELECT t FROM TraceProductUnit t WHERE t.ownUserID = :ownUserID"),
    @NamedQuery(name = "TraceProductUnit.findByAlterUserID", query = "SELECT t FROM TraceProductUnit t WHERE t.alterUserID = :alterUserID"),
    @NamedQuery(name = "TraceProductUnit.findByCreateTime", query = "SELECT t FROM TraceProductUnit t WHERE t.createTime = :createTime"),
    @NamedQuery(name = "TraceProductUnit.findByTimeStamp", query = "SELECT t FROM TraceProductUnit t WHERE t.timeStamp = :timeStamp")})
public class TraceProductUnit implements Serializable {
	public static byte[] EnCode(TraceProductUnit msg) throws IOException {
		Codec<TraceProductUnit> Lcode = ProtobufProxy.create(TraceProductUnit.class);
		return Lcode.encode(msg);
	}
	public static TraceProductUnit DeCode(byte[] data) throws IOException {
	Codec<TraceProductUnit> Lcode = ProtobufProxy.create(TraceProductUnit.class);
		return Lcode.decode(data);
	}

    private static final long serialVersionUID = 1L;
    @Id
    //@GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "sid")
    @Protobuf
	private Integer sid;
    @Basic(optional = false)
    @Column(name = "TraceType")
    @Protobuf
	private String traceType;
    @Basic(optional = false)
    @Column(name = "UnitID")
    @Protobuf
	private int unitID;
    @Basic(optional = false)
    @Column(name = "ProductID")
    @Protobuf
	private int productID;
    @Basic(optional = false)
    @Column(name = "UnitName")
    private String unitName;
	@Protobuf
	private byte[] unitNameBit;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "Net")
    @Protobuf
	private Float net;
    @Column(name = "Share")
    @Protobuf
	private long share;
    @Column(name = "StartDate")
    @Temporal(TemporalType.DATE)
    private Date startDate;
	@Protobuf
	private long startDateL;
    @Column(name = "EndDate")
    @Temporal(TemporalType.DATE)
    private Date endDate;
	@Protobuf
	private long endDateL;
    @Column(name = "BelongGroupID")
    @Protobuf
	private Integer belongGroupID;
    @Column(name = "OwnUserID")
    @Protobuf
	private String ownUserID;
    @Column(name = "AlterUserID")
    @Protobuf
	private String alterUserID;
    @Column(name = "CreateTime")
    @Temporal(TemporalType.TIMESTAMP)
    private Date createTime;
	//@Protobuf
//tprivate long createTimeL;
    @Column(name = "TimeStamp")
    @Temporal(TemporalType.TIMESTAMP)
    private Date timeStamp;
	//@Protobuf
	//private long timeStampL;

    public TraceProductUnit() {
    }

    public TraceProductUnit(Integer sid) {
        this.sid = sid;
    }

    public TraceProductUnit(Integer sid, String traceType, int unitID, int productID, String unitName) {
        this.sid = sid;
        this.traceType = traceType;
        this.unitID = unitID;
        this.productID = productID;
        this.unitName = unitName;
		this.unitNameBit = CodeTool.StringToBit(unitName);
    }

    public Integer getSid() {
        return sid;
    }

    public void setSid(Integer sid) {
        this.sid = sid;
    }

    public String getTraceType() {
        return traceType;
    }

    public void setTraceType(String traceType) {
        this.traceType = traceType;
    }

    public int getUnitID() {
        return unitID;
    }

    public void setUnitID(int unitID) {
        this.unitID = unitID;
    }

    public int getProductID() {
        return productID;
    }

    public void setProductID(int productID) {
        this.productID = productID;
    }

    public String getUnitName() {
        return unitName;
    }

    public void setUnitName(String unitName) {
        this.unitName = unitName;
        this.setUnitNameBit(CodeTool.StringToBit(unitName));
    }

    public Float getNet() {
        return net;
    }

    public void setNet(Float net) {
        this.net = net;
    }

    public long getShare() {
        return share;
    }

    public void setShare(long share) {
        this.share = share;
    }

    public Date getStartDate() {
        return startDate;
    }

    public void setStartDate(Date startDate) {
        this.startDate = startDate;
		this.setStartDateL(CodeTool.DateToLong(startDate));
    }

    public Date getEndDate() {
        return endDate;
    }

    public void setEndDate(Date endDate) {
        this.endDate = endDate;
		this.setEndDateL(CodeTool.DateToLong(endDate));
    }

    public Integer getBelongGroupID() {
        return belongGroupID;
    }

    public void setBelongGroupID(Integer belongGroupID) {
        this.belongGroupID = belongGroupID;
    }

    public String getOwnUserID() {
        return ownUserID;
    }

    public void setOwnUserID(String ownUserID) {
        this.ownUserID = ownUserID;
    }

    public String getAlterUserID() {
        return alterUserID;
    }

    public void setAlterUserID(String alterUserID) {
        this.alterUserID = alterUserID;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
		//this.createTimeL = CodeTool.DateToLong(createTime);
    }

    public Date getTimeStamp() {
        return timeStamp;
    }

    public void setTimeStamp(Date timeStamp) {
        this.timeStamp = timeStamp;
		//this.timeStampL = CodeTool.DateToLong(timeStamp);
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (sid != null ? sid.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TraceProductUnit)) {
            return false;
        }
        TraceProductUnit other = (TraceProductUnit) object;
        if ((this.sid == null && other.sid != null) || (this.sid != null && !this.sid.equals(other.sid))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.jili.ubert.dao.trace.TraceProductUnit[ sid=" + sid + " ]";
    }

    public byte[] getUnitNameBit() {
        return unitNameBit;
    }

    public void setUnitNameBit(byte[] unitNameBit) {
        this.unitNameBit = unitNameBit;
		this.unitName = CodeTool.BitToString(unitNameBit);
    }

    public long getStartDateL() {
        return startDateL;
    }

    public void setStartDateL(long startDateL) {
        this.startDateL = startDateL;
		this.startDate = CodeTool.LongToDate(startDateL);
    }

    public long getEndDateL() {
        return endDateL;
    }

    public void setEndDateL(long endDateL) {
        this.endDateL = endDateL;
		this.endDate = CodeTool.LongToDate(endDateL);
    }
    
}
